<template>
  <div class="homepage">
    <HomeSwiper :banner="data.banner"></HomeSwiper>
    <div class="live">
      <h1>乐享生活100+</h1>
      <div class="live-list">
        <div
            class="live-item"
            v-for="(item,index) in data.sports"
        >
          <div class="live-btn">
            <img
                :src="item.imgSrc"
                :alt="item.name"
            />
            <h3>{{item.name}}</h3>
          </div>
        </div>
      </div>
      <a-button type="primary" size="large" @click="router.push('/product')"
      >立即享受生活</a-button
      >
    </div>
  </div>
</template>

<script setup>
import HomeSwiper from './home-swiper.vue';
import {getHomepage} from '../../api/axios-utils';
import { useRouter } from "vue-router";
import{ reactive} from "vue";
const router = useRouter();
const result = await getHomepage();
const data = reactive({banner: result.data.banner, sports: result.data.sports});
</script>

<style scoped lang="less">
.homepage {
  height: 575px;
  position: relative;
}


.live {
  width: 1200px;
  margin: 40px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 40px;
  h1 {
    font-size: 30px;
  }

  .live-list {
    display: flex;
    flex-wrap: wrap;
    .live-item {
      width: 240px;
    }
    .live-btn {
      display: flex;
      height: 73px;
      width: 200px;
      background-color: #fff;
      border-radius: 8px 8px 25px 8px;
      margin-bottom: 30px;
      box-shadow: 5px 5px 5px #ccc;
      align-items: center;
      justify-content: center;
      position: relative;
      img {
        position: absolute;
        width: 80px;
        height: 60px;
        left: -15px;
        top: -15px;
      }
      h3 {
        font-weight: 900;
        font-size: 20px;
      }
    }
  }
}
</style>
